#include "stdafx.h"
#include "VehiculeGraphic.h"
#include "CameraFixFollowing.h"

namespace PM3D
{
    CameraFixFollowing::CameraFixFollowing(VehiculeGraphic *car, 
        Dispositif* d3dDevice, bool (*test)() ):
    CameraModel(d3dDevice,test),car_(car)
    {
        assert(car!=0);
        upAxis_ = D3DXVECTOR3(0.0f,0.0f,1.0f);
    }


    CameraFixFollowing::~CameraFixFollowing()
    {
    }

    void CameraFixFollowing::update(float ecartTemp)
    {
        D3DXVECTOR3 car = car_->getPosition();

        if (car.x > 500.0f && car.y < 500.0f)// plus bas pour le tunnel
            eye_ = D3DXVECTOR3(915.0f,90.0f,50.0f);
        else
        {
            eye_ = D3DXVECTOR3((car.x < 500.0f) ? (250.0f) :(750.0f),
                (car.y < 500.0f) ? (250.0f) :(750.0f),
                170.0f);
        }

        lookAt_ = car;
        upAxis_ = D3DXVECTOR3(0.0f,0.0f,1.0f);
        CameraModel::update(ecartTemp);
    }

} // fin namespace
